package com.lixinlei.tech.collection.collections;

import com.lixinlei.tech.collection.collections.bo.MultipleLoadCommunitySearchItem;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class CollectionsDemo {

    public static void main(String[] args) {
        assembleHotTop();
    }

    private static void assembleHotTop() {
        List<MultipleLoadCommunitySearchItem> items = new ArrayList<>();

        MultipleLoadCommunitySearchItem item1 = new MultipleLoadCommunitySearchItem();
        item1.setItemId(1);
        item1.setItemType(0);
        item1.setSource("community");
        item1.setItemScore(10.0);
        items.add(item1);

        MultipleLoadCommunitySearchItem item2 = new MultipleLoadCommunitySearchItem();
        item2.setItemId(1);
        item2.setItemType(0);
        item2.setSource("community");
        item2.setItemScore(20.0);
        items.add(item2);

        MultipleLoadCommunitySearchItem item3 = new MultipleLoadCommunitySearchItem();
        item3.setItemId(1);
        item3.setItemType(0);
        item3.setSource("community");
        item3.setItemScore(5.0);
        items.add(item3);

        for (MultipleLoadCommunitySearchItem item : items) {
            System.out.println(item.getItemScore());
        }

        System.out.println();

        System.out.println(Collections.max(items, new Comparator<MultipleLoadCommunitySearchItem>() {
            @Override
            public int compare(MultipleLoadCommunitySearchItem o1, MultipleLoadCommunitySearchItem o2) {
                if (o1.getItemScore() < o2.getItemScore()) {
                    return -1;
                } else if (o1.getItemScore() > o2.getItemScore()) {
                    return 1;
                } else {
                    return 0;
                }
            }
        }).getItemScore());

//        for (MultipleLoadCommunitySearchItem item : items) {
//            System.out.println(item.getItemScore());
//        }
    }

}
